package com.ruoyi.system.domain;

import java.math.BigDecimal;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseIdEntity;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;

/**
 * 会员等级规则对象 yh_member_level_rule
 * 
 * @author ruoyi
 * @date 2023-06-06
 */
@Data
@ApiModel(value = "YhMemberLevelRule", description = "会员等级规则对象")
public class YhMemberLevelRule extends BaseIdEntity
{
    private static final long serialVersionUID = 1L;

    /** id */
    @ApiModelProperty("id")
    private String id;

    /** 会员等级（非会员默认1级） */
    @Excel(name = "会员等级", readConverterExp = "非=会员默认1级")
    @ApiModelProperty("会员等级（非会员默认1级）")
    private Integer memberLevel;

    /** 价格 */
    @Excel(name = "价格")
    @ApiModelProperty("价格")
    private Double price;

    /** 每日允许扫码次数 */
    @Excel(name = "每日允许扫码次数")
    @ApiModelProperty("每日允许扫码次数")
    private Long allowCount;

    /** 佣金比例 */
    @Excel(name = "佣金比例")
    @ApiModelProperty("佣金比例")
    private Double commissionRate;

    /** 积分比例 */
    @Excel(name = "积分比例")
    @ApiModelProperty("积分比例")
    private Double pointRate;

    /** 创建者 */
    @ApiModelProperty("创建者")
    @TableField(fill = FieldFill.INSERT)
    private String createBy;

    /** 创建时间 */
    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /** 更新者 */
    @ApiModelProperty("更新者")
    @TableField(fill = FieldFill.UPDATE)
    private String updateBy;

    /** 更新时间 */
    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    public <T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> wrapper=new QueryWrapper<>();

        wrapper.eq(StringUtils.isNotEmpty(id),"id" , id);
        wrapper.eq(memberLevel != null,"member_level" , memberLevel);
        wrapper.eq(price != null,"price" , price);
        wrapper.eq(allowCount != null,"allow_count" , allowCount);
        wrapper.eq(commissionRate != null,"commission_rate" , commissionRate);
        wrapper.eq(pointRate != null,"point_rate" , pointRate);
        wrapper.eq(StringUtils.isNotEmpty(createBy),"create_by" , createBy);
        wrapper.eq(StringUtils.isNotEmpty(updateBy),"update_by" , updateBy);
        return wrapper;
    }

}
